package com.anghui.demo.vo.response;

public class R<T> {
    private int code;
    private String message;
    private T data;

    public R(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static R fail(int code, String message) {
        return new R(code, message, null);
    }

    public static R ok() {
        return R.ok(null);
    }

    public static R ok(String message) {
        return R.ok(message, null);
    }

    public static <T> R<T> ok(T data) {
        return R.ok(null, data);
    }

    public static <T> R<T> ok(String message, T data) {
        return new R<>(200, message, data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
